{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 逻辑回归\n",
    "* 包的导入\n",
    "* 数据读取\n",
    "* 划分训练集和测试集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.metrics import recall_score,precision_score,accuracy_score\n",
    "import pickle\n",
    "\n",
    "with open(r'分类数据.pkl',\"rb\") as f:\n",
    "    data,label = pickle.load(f)\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(data, label, train_size = 0.75, test_size = 0.25, random_state=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 建立逻辑回归模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "权重:\n",
      " [[ 1.78363181 -2.04516561]]\n",
      "偏置:\n",
      " [2.72013562]\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/zu/anaconda3/lib/python3.7/site-packages/sklearn/linear_model/logistic.py:433: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.\n",
      "  FutureWarning)\n"
     ]
    }
   ],
   "source": [
    "'''\n",
    "    LogisticRegression\n",
    "    \n",
    "    主要参数：\n",
    "    penalty：添加正则化方式，‘l1’，‘l2’，默认‘l2’\n",
    "    tol：设置误差，小于设置的值时停止\n",
    "    C：正则化强度的倒数\n",
    "    fit_intercept：是否将常数添加到决策函数中\n",
    "    solver：设置优化的方式，liblinear：坐标轴下降法优化\n",
    "                         lbfgs：拟牛顿法优化\n",
    "                         sag：小批量梯度下降法\n",
    "    max_iter：最大迭代次数\n",
    "    multi_class：分类方式选择参数，'ovr'或'multinomial'\n",
    "    n_jobs：并行数。int类型，默认为1。\n",
    "            1的时候，用CPU的一个内核运行程序，2的时候，用CPU的2个内核运行程序。\n",
    "            为-1的时候，用所有CPU的内核运行程序。\n",
    "    random_state：随机种子\n",
    "    \n",
    "    返回结果：\n",
    "    coef_：权重\n",
    "    intercept_：偏置\n",
    "'''\n",
    "\n",
    "model = LogisticRegression(random_state=0)\n",
    "model.fit(X_train,y_train)\n",
    "print(\"权重:\\n\",model.coef_)\n",
    "print(\"偏置:\\n\",model.intercept_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 查看测试集准确率\n",
    "* 查看数据分类效果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAD8CAYAAABjAo9vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3XdgVMXax/Hv7KYHAqH3Joj03gREmoAUURSwKwmhCypSBF9AQVRQQaSDKAjKlSKhV+m99ya9lwAJKbub3Xn/2IggLSGbnM3m+fxxL5s9Z85z7oVfZmfnzCitNUIIITyHyegChBBCuJYEuxBCeBgJdiGE8DAS7EII4WEk2IUQwsNIsAshhIeRYBdCCA8jwS6EEB5Ggl0IITyMlxEXzZYtmy5UqJARlxZCiDRrx44d17TW2R93nCHBXqhQIbZv327EpYUQIs1SSp1OzHEyFCOEEB5Ggl0IITyMBLsQQngYCXYhhPAwEuxCCOFhJNiFEMLDSLALIYSHkWAXQohUcD3mOj2W9OBW3K0Uv5YEuxBCpCCtNX8c+IOSY0oyetto1p5em+LXNOTJUyGESA8uRl2k86LO/Hn4TyrlrsTyt5dTNmfZFL+uBLsQQriY1popu6fw0dKPsNgtfNPgGz6s8SFeptSJXAl2IYRwoRM3ThA2P4yVJ1fyXMHnmNR8EsWyFkvVGi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xqa1jk94uRnIZ2Q9LlAVOK61PqG1tgK/Ay8ZXJPLaK0vaq13Jvw5Cmc45DW2KtdRSuUDmgKTjK7FlZRSQcBzwGQArbVVa33T2KpcJ00Gu1KqBXBea73H6FpSWDtgsdFFJFNe4Oxdr8/hQcF3N6VUIaACsMXYSlxqBM4OlMPoQlysCHAVmJIwzDRJKRVodFGuktzNrFOMUmoFkOsBb/UDPgVeSN2KXOdR96a1npdwTD+cH/Onp2ZtKUA94Gce9SkLQCmVAZgN9NBaRxpdjysopZoBV7TWO5RSzxtdj4t5ARWBblrrLUqpkUAf4DNjy3INtw12rXWDB/1cKVUGKAzsUUqBc6hip1Kqqtb6UiqW+MQedm//UEq9CzQD6uu0Px/1HJD/rtf5gAsG1ZIilFLeOEN9utZ6jtH1uFBNoIVS6kXADwhSSv2qtX7L4Lpc4RxwTmv9z6erWTiD3SOk+XnsSqlTQGWtdVpZxOeRlFKNge+AOlrrq0bXk1xKKS+cXwLXB84D24A3tNYHDC3MRZSzd/ELEKG17mF0PSklocfeU2vdzOhaXEUptQ4I1VofUUoNBAK11p8YXJZLuG2PPR37EfAFlid8Itmste5obElPTmsdr5TqCiwFzMBPnhLqCWoCbwP7lFK7E372qdZ6kYE1icTpBkxXSvkAJ4D3Da7HZdJ8j10IIcS90uSsGCGEEA8nwS6EEB5Ggl0IITyMBLsQQngYCXYhhPAwEuxCCOFhJNiFEMLDSLALIYSH+X/unLTndvXoxQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "准确率：\n",
      " 0.96\n"
     ]
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# 训练集预测结果\n",
    "y_pred = model.predict(X_test)\n",
    "\n",
    "# 绘制决策边界\n",
    "plt.scatter(X_test[:,0],X_test[:,1], marker='o',c=y_test,s=10)\n",
    "\n",
    "X= [i for i in range(-4,8,1)]\n",
    "Y = [-model.coef_[0][0]/model.coef_[0][1]*i-model.intercept_[0]/model.coef_[0][1] for i in X]\n",
    "plt.plot(X,Y,color='g',linestyle='-')\n",
    "plt.show()\n",
    "\n",
    "# 计算准确率\n",
    "print(\"准确率：\\n\",accuracy_score(y_true=y_test,y_pred=y_pred))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
